﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using WebService.DataAccess;using WebService.BusinessEntities;

namespace WebService.DataAccess
{
    /// <summary>
    /// Construct a UserInvitation object from a datareader.
    /// </summary>
    internal class GET_ALL_USER_INVITATIONS_PROCFactory : IDomainObjectFactory<UserInvitation>
    {
        public UserInvitation Construct(IDataReader reader)
        {
            UserInvitation userInvitation = new UserInvitation();

            int sent_byIndex = reader.GetOrdinal("sent_by");
            if (!reader.IsDBNull(sent_byIndex))
            {
                userInvitation.sent_by = reader.GetInt32(sent_byIndex);

            }

            int sent_toIndex = reader.GetOrdinal("sent_to");
            if (!reader.IsDBNull(sent_toIndex))
            {
                userInvitation.sent_to = reader.GetInt32(sent_toIndex);

            }

            int sent_dateIndex = reader.GetOrdinal("sent_date");
            if (!reader.IsDBNull(sent_dateIndex))
            {
                userInvitation.sent_date = reader.GetDateTime(sent_dateIndex);

            }

            int acceptation_dateIndex = reader.GetOrdinal("acceptation_date");
            if (!reader.IsDBNull(acceptation_dateIndex))
            {
                if (!reader.IsDBNull(acceptation_dateIndex))
                {
                    userInvitation.acceptation_date = reader.GetDateTime(acceptation_dateIndex);
                }

            }


            return userInvitation;
        }
    }
}

